<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>
    <include file="Public/sidebarstu"/>
    <div class="main-content">
        <div class="main-content-inner">
        <!-- 横向菜单 -->
           <include file="Public/stutopsidebar"/>
            <div class="page-content">
                 
                <div class="row">
                    <div class="widget-box ui-sortable-handle" style="opacity: 1; z-index: 0;">
                        <div class="widget-header">
                            <h5 class="widget-title">数据处理</h5>

                            <!-- #section:custom/widget-box.toolbar -->
                            <div class="widget-toolbar">
                                <div class="widget-menu">
                                    <a href="#" data-action="settings" data-toggle="dropdown">
                                        <i class="ace-icon fa fa-bars"></i>
                                    </a>

                                    <ul class="dropdown-menu dropdown-menu-right dropdown-light-blue dropdown-caret dropdown-closer">
                                        <li>
                                            <a data-toggle="tab" href="#dropdown1">Option#1</a>
                                        </li>

                                        <li>
                                            <a data-toggle="tab" href="#dropdown2">Option#2</a>
                                        </li>
                                    </ul>
                                </div>

                                <a href="#" data-action="fullscreen" class="orange2">
                                    <i class="ace-icon fa fa-expand"></i>
                                </a>

                                <a href="#" data-action="reload">
                                    <i class="ace-icon fa fa-refresh"></i>
                                </a>

                                <a href="#" data-action="collapse">
                                    <i class="ace-icon fa fa-chevron-up"></i>
                                </a>

                                <a href="#" data-action="close">
                                    <i class="ace-icon fa fa-times"></i>
                                </a>
                            </div>

                            <!-- /section:custom/widget-box.toolbar -->
                        </div>

                        <div class="widget-body">
                            <div class="widget-main">
                                <p class="alert alert-info">
                                    Nunc aliquam enim ut arcu aliquet adipiscing. Fusce dignissim volutpat justo non consectetur. Nulla fringilla eleifend consectetur.
                                </p>
                                <p class="alert alert-success">
                                    Raw denim you probably haven't heard of them jean shorts Austin.
                                </p>
                            </div>
                        </div>
                    </div>               
                </div>
            </div><!-- /.page-content -->
            <include file="Public/set"/>
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>

<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {

               //var remoteUrl="__ROOT__/testjson/tree.json";
               var remoteUrl='http://127.0.0.1/ace/examples/treeview.php';
               var remoteDateSource = function(options, callback) {
               var parent_id = null
               //var $sel=this;
               var $data=null;
                    if( !('text' in options || 'type' in options) ){
                     $.ajax({
                         url: remoteUrl,
                         data: 'parent_id=00',
                         type: 'POST',
                         dataType: 'json',
                         success : function(response) {
                            if(response.status == "OK")
                                　　　callback({ data: response.data });
                        　　　},
                        　  error: function(response) {
　　　　　　                        //console.log(response);
　　　　　                       　}
　　　　             });
                     return;
                    }
                    else if('type' in options && options['type'] == 'folder') {        
                        if  ('additionalParameters' in options && 'children' in options.additionalParameters){
                                 //parent_id = options.additionalParameters['id'];
                            $data = options.additionalParameters.children;//点击父节点，加载子节点
                        }
　　　　                else{ 
                                $data =null;//no data
                             }
                    }
                    if($data !== null) {
　　　　             setTimeout(function(){callback({ data: $data });} , parseInt(Math.random() * 500) + 200);
                        // $.ajax({
                        //     url: remoteUrl,
                        //     data: 'id='+parent_id,
                        //     type: 'POST',
                        //     dataType: 'json',
                        //     success : function(response) {
                        //         if(response.status == "OK")
                        //         {
                        //             callback({ data: response.data });
                        //         }
                        //     },
                        //     error: function(response) {
                                 
                        //     }
                        // })
                    }
                }
                $('#treeview').ace_tree({
                    dataSource: remoteDateSource ,
                    multiSelect: true,
                    loadingHTML: '<div class="tree-loading"><i class="ace-icon fa fa-refresh fa-spin blue"></i></div>',
                    'open-icon' : 'ace-icon tree-minus hide',
                    'close-icon' : 'ace-icon tree-plus hide',
                    'selectable' : false,
                    'selected-icon' : 'ace-icon fa fa-check',
                    'unselected-icon' : 'ace-icon fa fa-times',
                     cacheItems: true,
                     folderSelect: true,
                    'folder-open-icon' : 'ace-icon tree-plus',
                    'folder-close-icon' : 'ace-icon tree-minus'
                });

       
        $('#treesubmit').on('click', function() {
                    var output = '';
                    var items = $('#treeview').tree('selectedItems');
                    for(var i in items) if (items.hasOwnProperty(i)) {
                        var item = items[i];
                        output += item.additionalParameters['id'] + ":"+ item.text+"\n";
                    }
                    
                    alert(output);
                
                });

                
               


    })
</script>
</body>
</html>
